package frog.lazy.framework.core.tools;

import cn.hutool.core.date.DateUtil;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class DateUtils extends DateUtil {

    public static final DateTimeFormatter YYYY_MM_DD_HH_MM_DD = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    public static final DateTimeFormatter YYYY_MM_DD_HH_MM_DD_SSS = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssSSS");
    public static final DateTimeFormatter YYYY_MM_DD = DateTimeFormatter.ofPattern("yyyy-MM-dd");
    public static final DateTimeFormatter HH_MM_DD = DateTimeFormatter.ofPattern("HH:mm:ss");
    public static final LocalDate MAX_DATE = LocalDate.of(9999, 12, 31);

    public static Date date(Long datatime){
        return DateUtil.date(datatime);
    }

    public static LocalDateTime toLocalDateTime(String dateTime){
        return toLocalDateTime(dateTime, YYYY_MM_DD_HH_MM_DD);
    }

    public static LocalDateTime toLocalDateTime(String dateTime, DateTimeFormatter formatter){
        return LocalDateTime.parse(dateTime, formatter);
    }

    public static String toString(LocalDateTime localDateTime){
        return localDateTime.format(YYYY_MM_DD_HH_MM_DD);
    }

    public static String toString(LocalDateTime localDateTime, DateTimeFormatter formatter){
        return localDateTime.format(formatter);
    }

    public static void main(String args[]){
        System.out.print(toLocalDateTime("2020-02-10 16:01:03797"));
    }
}
